import time
import threading
from communication import *

class Pinger(threading.Thread):
  def __init__(self, peer_manager):
    threading.Thread.__init__(self)
    self._pman = peer_manager
    self._fman = peer_manager.filemanager
    
  def run(self):
    while 1:
      for peer in self._pman.nlist:
        changelist = None
        if self._fman.change:
          changelist = self._fman.changelist
        self._pman.comm(peer, PING, changelist)
      self._fman.sent()
      time.sleep(300)
